import axios from "axios";
import { serialize } from "../utils/utils";

//默认超时时间
axios.defaults.timeout = 30000;

//http request拦截
axios.interceptors.request.use(
  (config) => {
    //headers中配置serialize为true开启序列化
    if (config.method === "post") {
      config.data = serialize(config.data);
    }
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default axios;
